<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 2018/10/9
 * Time: 14:44
 */

namespace home\modules\docu\models;


use yii\base\Model;
use yii\data\ActiveDataProvider;

class FormDocuSearch extends Model
{
    public $title;

    public function rules()
    {
        return [
//            ['title', 'required'],
            ['title', 'string'],
        ];
    }

    public function searchDocu()
    {
        $query = Docu::find()->alias('docu')->where(['docu.status' => Docu::STATUS_DEFAULT]);
        $dataProvider = new ActiveDataProvider([
            'query'=>$query->andFilterWhere(['like', 'docu.title', $this->title]),
            'pagination'=>[
                'pageSize' => 10,
            ],
        ]);
        return $dataProvider;
    }
}